home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / system / mail / transpor / ifmail23.z / ifmail23 / ifmail / misc / nledit / differ.sh next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1994-02-20  |  1.9 KB  |  86 lines

  1. #!/bin/sh
  2. #
  3. # differ.sh        -    Make nodediffs
  4. #
  5. # $Header$
  6. #
  7. # (c)1994 Cees de Groot
  8. #
  9. # Description:
  10. #    This script uses the IFmail configuration file to find any nodediffs,
  11. #    and creates the new nodelists if necessary. 
  12. #
  13. # Copyright stuff:
  14. #    Don't want to include the complete legal shit here, but the GNU Public
  15. #    License, Version 2 or later, applies.
  16. #
  17. # Comments:
  18. #    You'd better be sure the correct set of nodelists is there. It expects
  19. #    exactly one nodelist, and a number of nodediffs. It applies all 
  20. #    nodediffs to the nodelist, leaving only the new nodelist. Error checking
  21. #    probably needs some extra attention...
  22.  
  23. #
  24. # Configuration file we need to browse and the nodelist editor
  25. #
  26. IFconfig=/usr/fido/lib/ifmail/config
  27. NLedit=/usr/fido/bin/nledit
  28.  
  29. #
  30. # Get the nodelists
  31. #
  32. Nodelists=`awk '/^nodelist/ { print $2}' $IFconfig`
  33.  
  34. #
  35. # Get the nodediffs. He? Yes, we get it from the config file. Please
  36. # make sure you use the same order...
  37. #
  38. Nodediffs=`awk '/^#nodediff/ { print $2}' $IFconfig`
  39. set - $Nodediffs
  40.  
  41. #
  42. # Walk through the nodelists. We use the path from the first nodelist,
  43. # like IFmail does
  44. #
  45. oldPath=`pwd`
  46. for curList in $Nodelists
  47. do
  48.     if [ -z "$nlPath" ]
  49.     then
  50.         nlPath=`dirname $curList`
  51.         cd $nlPath
  52.         curList=`basename $curList`
  53.     fi
  54.     oldList=`echo $curList.[0-9][0-9][0-9]`
  55.  
  56.     #
  57.     # Now for the hard stuff: find out the diffs. 
  58.     #
  59.     curDiff=$1
  60.     shift
  61.     echo "Trying to diff $oldList with $curDiff"
  62.  
  63.     diffCandidates=`echo $curDiff.[0-9][0-9][0-9] | sort`
  64.     if [ "$diffCandidates" != $curDiff'.[0-9][0-9][0-9]' ]
  65.     then
  66.         #
  67.         # Process all candidates in order. We assume the correct diffs
  68.         # are there.
  69.         #
  70.         for curCand in $diffCandidates
  71.         do
  72.             #
  73.             # Get the new nodelist name from the nodelist and the
  74.             # diff name
  75.             #
  76.             newList=$curList`echo $curCand|sed "s/$curDiff//"`
  77.             echo "Applying diff : $oldList -> $curCand -> $newList"
  78.             $NLedit $oldList $curCand $newList
  79.             rm $oldList $curCand 
  80.             oldList=$newList
  81.         done
  82.     fi
  83. done
  84.  
  85. cd $oldPath
  86.